<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: customers_status.php 42 2013-09-21 11:55:58Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 42 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:55:58 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

switch ($_GET['action']) {
    case 'insert':
    case 'save':
		$customers_status_id = ($_GET['cID']);

		$languages = get_languages();
		for ($i=0; $i<sizeof($languages); $i++) {
			$customers_status_name_array = $_POST['customers_status_name'];
			$customers_status_public = $_POST['customers_status_public'];
			$customers_status_show_price = $_POST['customers_status_show_price'];
			$customers_status_show_price_tax = $_POST['customers_status_show_price_tax'];
			$customers_status_min_order = $_POST['customers_status_min_order'];
			$customers_status_max_order = $_POST['customers_status_max_order'];
			$customers_status_discount = $_POST['customers_status_discount'];
			$customers_status_ot_discount_flag = $_POST['customers_status_ot_discount_flag'];
			$customers_status_ot_discount = $_POST['customers_status_ot_discount'];
			$customers_status_graduated_prices = $_POST['customers_status_graduated_prices'];
			$customers_status_discount_attributes = $_POST['customers_status_discount_attributes'];
			$customers_status_add_tax_ot = $_POST['customers_status_add_tax_ot'];
			$customers_status_payment_unallowed = $_POST['customers_status_payment_unallowed'];
			$customers_status_shipping_unallowed = $_POST['customers_status_shipping_unallowed'];
			$customers_fsk18 = $_POST['customers_fsk18'];
			$customers_fsk18_display = $_POST['customers_fsk18_display'];
			$customers_status_write_reviews = $_POST['customers_status_write_reviews'];
			$customers_status_read_reviews = $_POST['customers_status_read_reviews'];
			$customers_base_status = $_POST['customers_base_status'];

			$language_id = $languages[$i]['id'];

	        $sql_data_array = array('customers_status_name' => ($customers_status_name_array[$language_id]),
									'customers_status_public' => ($customers_status_public),
									'customers_status_show_price' => ($customers_status_show_price),
									'customers_status_show_price_tax' => ($customers_status_show_price_tax),
									'customers_status_min_order' => ($customers_status_min_order),
									'customers_status_max_order' => ($customers_status_max_order),
									'customers_status_discount' => ($customers_status_discount),
									'customers_status_ot_discount_flag' => ($customers_status_ot_discount_flag),
									'customers_status_ot_discount' => ($customers_status_ot_discount),
									'customers_status_graduated_prices' => ($customers_status_graduated_prices),
									'customers_status_add_tax_ot' => ($customers_status_add_tax_ot),
									'customers_status_payment_unallowed' => ($customers_status_payment_unallowed),
									'customers_status_shipping_unallowed' => ($customers_status_shipping_unallowed),
									'customers_fsk18' => ($customers_fsk18),
									'customers_fsk18_display' => ($customers_fsk18_display),
									'customers_status_write_reviews' => ($customers_status_write_reviews),
									'customers_status_read_reviews' => ($customers_status_read_reviews),
									'customers_status_discount_attributes' => ($customers_status_discount_attributes));

        if ($_GET['action'] == 'insert') {
			if (!not_null($customers_status_id)) {
				$next_id = $db->db_query("SELECT MAX(customers_status_id) AS customers_status_id FROM ".TABLE_CUSTOMERS_STATUS."");

				$customers_status_id = $next_id->fields['customers_status_id'] + 1;
				$db->db_query("CREATE TABLE ".TABLE_PERSONAL_OFFERS_BY.$customers_status_id." (price_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, products_id int NOT NULL, quantity int, personal_offer decimal(15,4))");
				$db->db_query("ALTER TABLE ".TABLE_PRODUCTS." ADD `group_permission_".$customers_status_id."` TINYINT(1) NOT NULL");
				$db->db_query("ALTER TABLE ".TABLE_CATEGORIES." ADD `group_permission_".$customers_status_id."` TINYINT(1) NOT NULL");

				$products = $db->db_query("SELECT price_id, products_id, quantity, personal_offer FROM ".TABLE_PERSONAL_OFFERS_BY.$customers_base_status ."");
				while(!$products->EOF){
					$product_data_array = array('price_id' => ($products->fields['price_id']),
												'products_id' => ($products->fields['products_id']),
												'quantity' => ($products->fields['quantity']),
												'personal_offer' => ($products->fields['personal_offer']));
					$db->db_perform(TABLE_PERSONAL_OFFERS_BY.$customers_status_id, $product_data_array);
					$products->MoveNext();
				}

			}

			$insert_sql_data = array('customers_status_id' => ($customers_status_id), 'language_id' => ($language_id));
			$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
			$db->db_perform(TABLE_CUSTOMERS_STATUS, $sql_data_array);

		} elseif ($_GET['action'] == 'save') {
			$db->db_perform(TABLE_CUSTOMERS_STATUS, $sql_data_array, 'update', "customers_status_id = ".($customers_status_id)." and language_id = '".$language_id."'");
		}
	}

      if ($customers_status_image = &try_upload('customers_status_image', DIR_WS_ICONS)) {
        $db->db_query("UPDATE
        					".TABLE_CUSTOMERS_STATUS."
        				SET
        					customers_status_image = '".$customers_status_image->filename."'
        				WHERE
        					customers_status_id = ".($customers_status_id));
      }

      if ($_POST['default'] == 'on') {
        $db->db_query("UPDATE
        					".TABLE_CONFIGURATION."
        				SET
        					configuration_value = ".$db->db_prepare($customers_status_id)."
        				WHERE
        					configuration_key = 'DEFAULT_CUSTOMERS_STATUS_ID'");
      }

      redirect(href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$customers_status_id));
      break;

    case 'deleteconfirm':
		$cID = ($_GET['cID']);

		$customers_status = $db->db_query("SELECT configuration_value from ".TABLE_CONFIGURATION." WHERE configuration_key = 'DEFAULT_CUSTOMERS_STATUS_ID'");

		if ($customers_status->fields['configuration_value'] == $cID)
			$db->db_query("UPDATE ".TABLE_CONFIGURATION." set configuration_value = '' WHERE configuration_key = 'DEFAULT_CUSTOMERS_STATUS_ID'");

		$db->db_query("DELETE FROM ".TABLE_CUSTOMERS_STATUS." WHERE customers_status_id = '".($cID)."'");

		$db->db_query("DROP TABLE IF EXISTS ".TABLE_PERSONAL_OFFERS_BY.$cID."");
		$db->db_query("ALTER TABLE ".TABLE_PRODUCTS." DROP `group_permission_".$cID."`");
		$db->db_query("ALTER TABLE ".TABLE_CATEGORIES." DROP `group_permission_".$cID."`");
		redirect(href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page']));
		break;

    case 'delete':
		$cID = ($_GET['cID']);

		$status = $db->db_query("SELECT COUNT(*) AS count FROM ".TABLE_CUSTOMERS." WHERE customers_status = '".$cID."'");

		$remove_status = true;
		if(($cID == DEFAULT_CUSTOMERS_STATUS_ID) || ($cID == DEFAULT_CUSTOMERS_STATUS_ID_GUEST) || ($cID == DEFAULT_CUSTOMERS_STATUS_ID_NEWSLETTER)) {
			$remove_status = false;
			$message_stack->add(ERROR_REMOVE_DEFAULT_CUSTOMERS_STATUS, 'error');

		} elseif ($status->fields['count'] > 0) {
			$remove_status = false;
			$message_stack->add(ERROR_STATUS_USED_IN_CUSTOMERS, 'error');

		} else {
			$history = $db->db_query("SELECT COUNT(*) AS count FROM ".TABLE_CUSTOMERS_STATUS_HISTORY." WHERE ".$db->db_prepare($cID)." IN (new_value, old_value)");
			if ($history->fields['count'] > 0) {
				$db->db_query("DELETE FROM ".TABLE_CUSTOMERS_STATUS_HISTORY." WHERE ".$db->db_prepare($cID)." IN (new_value, old_value)");
				$remove_status = true;
			}
		}
	break;
}
require(DIR_WS_INCLUDES.'metatag.php');
?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellpadding="0" cellspacing="0">
  <tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
		<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
	</td>
    <td  class="boxCenter" valign="top">
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td>
        <table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
  		<tr>
    		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  		</tr>
		</table>
		</td>
      </tr>
      <tr>
        <td valign="top">
		<?php
			if (substr($_GET['action'], 0, 3) != 'new') {
		?>
		<tr>
			<td colspan="3" align="right">
				<?php echo '<a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&action=new').'">'.BUTTON_INSERT.'</a>'; ?>
			</td>
		</tr>
		<?php
		}
		?>
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table width="100%" class="dataTable" cellspacing="0" cellpadding="0">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent" align="left" width=""><?php echo 'Grafik'; ?></td>
                <td class="dataTableHeadingContent" align="left" width=""><?php echo 'User'; ?></td>
                <td class="dataTableHeadingContent" align="left" width=""><?php echo TABLE_HEADING_CUSTOMERS_STATUS; ?></td>
                <td class="dataTableHeadingContent" align="center" width=""><?php echo TABLE_HEADING_TAX_PRICE; ?></td>
                <td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_DISCOUNT; ?></td>
                <td class="dataTableHeadingContent" width=""><?php echo TABLE_HEADING_CUSTOMERS_GRADUATED; ?></td>
                <td class="dataTableHeadingContent" width="100"><?php echo TABLE_HEADING_CUSTOMERS_UNALLOW; ?></td>
                <td class="dataTableHeadingContent" width="100"><?php echo TABLE_HEADING_CUSTOMERS_UNALLOW_SHIPPING; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
				<?php
				  $customers_status_ot_discount_flag_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_graduated_prices_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_public_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_show_price_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_show_price_tax_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_discount_attributes_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_add_tax_ot_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_fsk18_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_fsk18_display_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_write_reviews_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));
				  $customers_status_read_reviews_array = array(array('id' => '0', 'text' => ENTRY_NO), array('id' => '1', 'text' => ENTRY_YES));

				  $customers_status_sql = "SELECT * from ".TABLE_CUSTOMERS_STATUS." WHERE language_id = '".$_SESSION['languages_id']."' ORDER BY customers_status_id";

				  $query = page_break_create($_POST['per_site'], $_GET['page'], $customers_status_sql, 'customers_status.php');

				  $customers_status = $query['query'];

				  $i=1;
				  while(!$customers_status->EOF) {
				    if (((!$_GET['cID']) || ($_GET['cID'] == $customers_status->fields['customers_status_id'])) && (!$cInfo) && (substr($_GET['action'], 0, 3) != 'new')) {
				      $cInfo = new objectInfo($customers_status->fields);
				    }

				    if ( (is_object($cInfo)) && ($customers_status->fields['customers_status_id'] == $cInfo->customers_status_id) ) {
				      echo '<tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'pointer\'" onclick="document.location.href=\''.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id.'&action=edit').'\'">'."\n";
				    } else {
				    if ($i % 2 == 0)
			    		$f = 'dataTableRow';
			    	else
			    		$f = '';
				      echo '<tr class="'.$f.'" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'pointer\'" onmouseout="this.className=\''.$f.'\'" onclick="document.location.href=\''.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$customers_status->fields['customers_status_id']).'\'">'."\n";
				    }

				    echo '<td class="dataTableContent" align="left">';
				     if ($customers_status->fields['customers_status_image'] != '') {
				       echo image(DIR_WS_ICONS.$customers_status->fields['customers_status_image'] , IMAGE_ICON_INFO);
				     }
				     echo '</td>';

				     echo '<td class="dataTableContent" align="left">';
				     echo get_status_users($customers_status->fields['customers_status_id']);
				     echo '</td>';

				    if ($customers_status->fields['customers_status_id'] == DEFAULT_CUSTOMERS_STATUS_ID ) {
				      echo '<td class="dataTableContent" align="left"><b>'.$customers_status->fields['customers_status_name'];
				      echo ' ('.TEXT_DEFAULT.')';
				    } else {
				      echo '<td class="dataTableContent" align="left">'.$customers_status->fields['customers_status_name'];
				    }
				    if ($customers_status->fields['customers_status_public'] == '1') {
				      echo ' <em class="fs85">öffentlich</em>';
				    }
				    echo '</b></td>';

				    if ($customers_status->fields['customers_status_show_price'] == '1') {
				      echo '<td nowrap class="dataTableContent" align="center"> ';
				      if ($customers_status->fields['customers_status_show_price_tax'] == '1') {
				        echo TAX_YES;
				      } else {
				        echo TAX_NO;
				      }
				    } else {
				      echo '<td class="dataTableContent" align="left"> ';
				    }
				    echo '</td>';

				    echo '<td nowrap class="dataTableContent" align="center">'.$customers_status->fields['customers_status_discount'].' %</td>';

				    echo '<td nowrap class="dataTableContent" align="center">';
				    if ($customers_status->fields['customers_status_ot_discount_flag'] == 0){
				      echo '<span style="color:#b20000">'.$customers_status->fields['customers_status_ot_discount'].' %</span>';
				    } else {
				      echo $customers_status->fields['customers_status_ot_discount'].' %';
				    }
				    echo ' </td>';

				    echo '<td class="dataTableContent" align="center">';
				    if ($customers_status->fields['customers_status_graduated_prices'] == 0) {
				      echo NO;
				    } else {
				      echo YES;
				    }
				    echo '</td>';
				    echo '<td nowrap class="dataTableContent" align="center">'.$customers_status->fields['customers_status_payment_unallowed'].'&nbsp;</td>';
				    echo '<td nowrap class="dataTableContent" align="center">'.$customers_status->fields['customers_status_shipping_unallowed'].'&nbsp;</td>';
				    echo "\n";
				?>
				  <td class="dataTableContent" align="right">
				  	<?php
				  	if((is_object($cInfo)) && ($customers_status->fields['customers_status_id'] == $cInfo->customers_status_id))
				  		echo image(DIR_WS_IMAGES.'icon_arrow_right.gif', '');
				  	else {
				  		echo '<a href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$customers_status->fields['customers_status_id']).'">'.image(DIR_WS_IMAGES.'icons/information.png', IMAGE_ICON_INFO).'</a>';
				  		echo ' <a href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$customers_status->fields['customers_status_id'].'&action=edit').'">'.image(DIR_WS_IMAGES.'icons/layer--pencil.png', IMAGE_ICON_EDIT).'</a>';
				  	} ?>&nbsp;</td>
				<?php
					echo '</tr>';
				  $i++;
				  $customers_status->MoveNext();
				  }
				?>
            </table><br />
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tr class="page_break">
					<td class="smallText" valign="top" width="33.33%">
						<?php echo 'Angezeigt werden '.$query['from'].' bis '.$query['to'].' (von insgesamt '.$query['total'].')'; ?>
					</td>
					<td class="smallText" align="right" width="33.33%"></td>
					<td align="right" width="33.33%">
						<?php
							echo 'pro Seite: '.$query['page_break']->perSiteDropdown($_GET['page']);
						?>
					</td>
				</tr>
				<tr><td align="center" colspan="3"><?php echo '<br />'.$query['links']; ?></td></tr>
                </table>
            </td>
			<?php
			  $heading = array();
			  $contents = array();
			  switch ($_GET['action']) {
			    case 'new':
			      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_NEW_CUSTOMERS_STATUS.'</b>');
			      $contents = array('form' => draw_form('status', FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&action=insert', 'post', 'enctype="multipart/form-data"'));
			      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
			      $customers_status_inputs_string = '';
			      $languages = get_languages();
			      for ($i=0; $i<sizeof($languages); $i++) {
			        $customers_status_inputs_string .= '<br />'.image(DIR_WS_CATALOG.'lang/'.$languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']).'&nbsp;'.draw_input_field('customers_status_name['.$languages[$i]['id'].']');
			      }
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_NAME.$customers_status_inputs_string);
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_IMAGE.'<br />'.draw_file_field('customers_status_image'));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_PUBLIC_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_PUBLIC.' '.draw_pull_down_menu('customers_status_public', $customers_status_public_array, $cInfo->customers_status_public ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_MIN_ORDER_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_MIN_ORDER.' '.draw_input_field('customers_status_min_order', $cInfo->customers_status_min_order ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_MAX_ORDER_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_MAX_ORDER.' '.draw_input_field('customers_status_max_order', $cInfo->customers_status_max_order ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHOW_PRICE_INTRO    .'<br />'.ENTRY_CUSTOMERS_STATUS_SHOW_PRICE.' '.draw_pull_down_menu('customers_status_show_price', $customers_status_show_price_array, $cInfo->customers_status_show_price ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHOW_PRICE_TAX_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_SHOW_PRICE_TAX.' '.draw_pull_down_menu('customers_status_show_price_tax', $customers_status_show_price_tax_array, $cInfo->customers_status_show_price_tax ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_ADD_TAX_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_ADD_TAX.' '.draw_pull_down_menu('customers_status_add_tax_ot', $customers_status_add_tax_ot_array, $cInfo->customers_status_add_tax_ot));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE_INTRO.'<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE.'<br />'.draw_input_field('customers_status_discount', $cInfo->customers_status_discount));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES_INTRO    .'<br />'.ENTRY_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES.' '.draw_pull_down_menu('customers_status_discount_attributes', $customers_status_discount_attributes_array, $cInfo->customers_status_discount_attributes ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_OT_XMEMBER_INTRO.'<br /> '.ENTRY_OT_XMEMBER.' '.draw_pull_down_menu('customers_status_ot_discount_flag', $customers_status_ot_discount_flag_array, $cInfo->customers_status_ot_discount_flag ). '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE.'<br />'.draw_input_field('customers_status_ot_discount', $cInfo->customers_status_ot_discount));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_GRADUATED_PRICES_INTRO.'<br />'.ENTRY_GRADUATED_PRICES.' '.draw_pull_down_menu('customers_status_graduated_prices', $customers_status_graduated_prices_array, $cInfo->customers_status_graduated_prices ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES.' '.draw_pull_down_menu('customers_status_discount_attributes', $customers_status_discount_attributes_array, $cInfo->customers_status_discount_attributes ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_PAYMENT_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_PAYMENT_UNALLOWED.' '.draw_input_field('customers_status_payment_unallowed', $cInfo->customers_status_payment_unallowed ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHIPPING_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_SHIPPING_UNALLOWED.' '.draw_input_field('customers_status_shipping_unallowed', $cInfo->customers_status_shipping_unallowed ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_FSK18_INTRO.'<br />'.ENTRY_CUSTOMERS_FSK18.' '.draw_pull_down_menu('customers_fsk18', $customers_fsk18_array, $cInfo->customers_fsk18));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_FSK18_DISPLAY_INTRO.'<br />'.ENTRY_CUSTOMERS_FSK18_DISPLAY.' '.draw_pull_down_menu('customers_fsk18_display', $customers_fsk18_display_array, $cInfo->customers_fsk18_display));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_WRITE_REVIEWS_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_WRITE_REVIEWS.' '.draw_pull_down_menu('customers_status_write_reviews', $customers_status_write_reviews_array, $cInfo->customers_status_write_reviews));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_READ_REVIEWS_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_READ_REVIEWS.' '.draw_pull_down_menu('customers_status_read_reviews', $customers_status_read_reviews_array, $cInfo->customers_status_read_reviews));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_BASE.'<br />'.ENTRY_CUSTOMERS_STATUS_BASE.'<br />'.draw_pull_down_menu('customers_base_status', get_customers_statuses()));
			      $contents[] = array('text' => '<br />'.draw_checkbox_field('default').' '.TEXT_SET_DEFAULT);
			      $contents[] = array('align' => 'center', 'text' => '<br /><input type="submit" class="button" onclick="this.blur();" value="'.BUTTON_INSERT.'"/> <a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page']).'">'.BUTTON_CANCEL.'</a>');
			      break;

			    case 'edit':
			      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_EDIT_CUSTOMERS_STATUS.'</b>');
			      $contents = array('form' => draw_form('status', FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id  .'&action=save', 'post', 'enctype="multipart/form-data"'));
			      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
			      $customers_status_inputs_string = '';
			      $languages = get_languages();
			      for ($i=0; $i<sizeof($languages); $i++) {
			        $customers_status_inputs_string .= '<br />'.image(DIR_WS_CATALOG.'lang/'.$languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']).'&nbsp;'.draw_input_field('customers_status_name['.$languages[$i]['id'].']', get_customers_status_name($cInfo->customers_status_id, $languages[$i]['id']));
			      }

			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_NAME.$customers_status_inputs_string);
			      $contents[] = array('text' => '<br />'.image(DIR_WS_ICONS.$cInfo->customers_status_image, $cInfo->customers_status_name).'<br />'.DIR_WS_ICONS.'<b>'.$cInfo->customers_status_image.'</b>');
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_IMAGE.'<br />'.draw_file_field('customers_status_image', $cInfo->customers_status_image));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_PUBLIC_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_PUBLIC.' '.draw_pull_down_menu('customers_status_public', $customers_status_public_array, $cInfo->customers_status_public ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_MIN_ORDER_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_MIN_ORDER.' '.draw_input_field('customers_status_min_order', $cInfo->customers_status_min_order ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_MAX_ORDER_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_MAX_ORDER.' '.draw_input_field('customers_status_max_order', $cInfo->customers_status_max_order ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHOW_PRICE_INTRO    .'<br />'.ENTRY_CUSTOMERS_STATUS_SHOW_PRICE.' '.draw_pull_down_menu('customers_status_show_price', $customers_status_show_price_array, $cInfo->customers_status_show_price ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHOW_PRICE_TAX_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_SHOW_PRICE_TAX.' '.draw_pull_down_menu('customers_status_show_price_tax', $customers_status_show_price_tax_array, $cInfo->customers_status_show_price_tax ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_ADD_TAX_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_ADD_TAX.' '.draw_pull_down_menu('customers_status_add_tax_ot', $customers_status_add_tax_ot_array, $cInfo->customers_status_add_tax_ot));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE_INTRO.'<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE.' '.draw_input_field('customers_status_discount', $cInfo->customers_status_discount));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES.' '.draw_pull_down_menu('customers_status_discount_attributes', $customers_status_discount_attributes_array, $cInfo->customers_status_discount_attributes ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_OT_XMEMBER_INTRO.'<br /> '.ENTRY_OT_XMEMBER.' '.draw_pull_down_menu('customers_status_ot_discount_flag', $customers_status_ot_discount_flag_array, $cInfo->customers_status_ot_discount_flag). '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE.' '.draw_input_field('customers_status_ot_discount', $cInfo->customers_status_ot_discount));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_GRADUATED_PRICES_INTRO.'<br />'.ENTRY_GRADUATED_PRICES.' '.draw_pull_down_menu('customers_status_graduated_prices', $customers_status_graduated_prices_array, $cInfo->customers_status_graduated_prices));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_PAYMENT_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_PAYMENT_UNALLOWED.' '.draw_input_field('customers_status_payment_unallowed', $cInfo->customers_status_payment_unallowed ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHIPPING_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_SHIPPING_UNALLOWED.' '.draw_input_field('customers_status_shipping_unallowed', $cInfo->customers_status_shipping_unallowed ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_FSK18_INTRO.'<br />'.ENTRY_CUSTOMERS_FSK18.' '.draw_pull_down_menu('customers_fsk18', $customers_fsk18_array, $cInfo->customers_fsk18 ));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_FSK18_DISPLAY_INTRO.'<br />'.ENTRY_CUSTOMERS_FSK18_DISPLAY.' '.draw_pull_down_menu('customers_fsk18_display', $customers_fsk18_display_array, $cInfo->customers_fsk18_display));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_WRITE_REVIEWS_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_WRITE_REVIEWS.' '.draw_pull_down_menu('customers_status_write_reviews', $customers_status_write_reviews_array, $cInfo->customers_status_write_reviews));
			      $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_READ_REVIEWS_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_READ_REVIEWS.' '.draw_pull_down_menu('customers_status_read_reviews', $customers_status_read_reviews_array, $cInfo->customers_status_read_reviews));

			      if (DEFAULT_CUSTOMERS_STATUS_ID != $cInfo->customers_status_id) $contents[] = array('text' => '<br />'.draw_checkbox_field('default').' '.TEXT_SET_DEFAULT);
			      $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'.BUTTON_UPDATE.'</button> <a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id).'">'.BUTTON_CANCEL.'</a>');
			      break;

			    case 'delete':
			      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_DELETE_CUSTOMERS_STATUS.'</b>');

			      $contents = array('form' => draw_form('status', FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id .'&action=deleteconfirm'));
			      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
			      $contents[] = array('text' => '<br /><b>'.$cInfo->customers_status_name.'</b>');

			      if ($remove_status) $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'.BUTTON_DELETE.'</button> <a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id).'">'.BUTTON_CANCEL.'</a>');
			      break;

			    default:
			      if (is_object($cInfo)) {
			        $heading[] = array('text' => '<b>'.$cInfo->customers_status_name.'</b>');

			        $contents[] = array('align' => 'center', 'text' => '<br /><a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id.'&action=edit').'">'.BUTTON_EDIT.'</a> <a class="button" onclick="this.blur();" href="'.href_link(FILENAME_CUSTOMERS_STATUS, 'page='.$_GET['page'].'&cID='.$cInfo->customers_status_id.'&action=delete').'">'.BUTTON_DELETE.'</a>');
			        $customers_status_inputs_string = '';
			        $languages = get_languages();
			        for ($i=0; $i<sizeof($languages); $i++) {
			          $customers_status_inputs_string .= '<br />'.image(DIR_WS_CATALOG.'lang/'. $languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']).'&nbsp;'.get_customers_status_name($cInfo->customers_status_id, $languages[$i]['id']);
			        }
			        $contents[] = array('text' => $customers_status_inputs_string);
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE_INTRO.'<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_PRICE.' '.$cInfo->customers_status_discount.'%');
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_OT_XMEMBER_INTRO.'<br />'.ENTRY_OT_XMEMBER.' '.$customers_status_ot_discount_flag_array[$cInfo->customers_status_ot_discount_flag]['text'].' ('.$cInfo->customers_status_ot_discount_flag.')'.' - '.$cInfo->customers_status_ot_discount.'%');
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_GRADUATED_PRICES_INTRO.'<br />'.ENTRY_GRADUATED_PRICES.' '.$customers_status_graduated_prices_array[$cInfo->customers_status_graduated_prices]['text'].' ('.$cInfo->customers_status_graduated_prices.')' );
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_DISCOUNT_ATTRIBUTES.' '.$customers_status_discount_attributes_array[$cInfo->customers_status_discount_attributes]['text'].' ('.$cInfo->customers_status_discount_attributes.')' );
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_PAYMENT_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_PAYMENT_UNALLOWED.':<b> '.$cInfo->customers_status_payment_unallowed.'</b>');
			        $contents[] = array('text' => '<br />'.TEXT_INFO_CUSTOMERS_STATUS_SHIPPING_UNALLOWED_INTRO.'<br />'.ENTRY_CUSTOMERS_STATUS_SHIPPING_UNALLOWED.':<b> '.$cInfo->customers_status_shipping_unallowed.'</b>');
			      }
			      break;
			  }

			  if ( (not_null($heading)) && (not_null($contents)) ) {
			    echo '<td width="25%" class="border" valign="top">'."\n";
			    $box = new box;
			    echo $box->infoBox($heading, $contents);
			    echo '</td>'."\n";
			  }
			?>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>